# coding=utf-8
from django.shortcuts import render_to_response
from django.core.exceptions import ObjectDoesNotExist
from apps.cooperation.models import Cooperation
from apps.research.views import head_group

def cooperation(request, lang):
#   语言检验
    if lang != 'en' and lang != 'zh':
        return render_to_response('404.html', {'error': 'Unkown language error'})
    enterprises = list(Cooperation.objects.filter(cooperation_type='E'))
    governments = list(Cooperation.objects.filter(cooperation_type='G'))
    universities = list(Cooperation.objects.filter(cooperation_type='U'))

    return render_to_response('cooperation.html', {
        'current_item': 'cooperation',
        'lang': lang,
        'url_en': '/en/cooperation/',
        'url_zh': '/zh/cooperation/',
        'head_group_list': head_group(),
        'enterprises': enterprises,
        'governments': governments,
        'universities': universities})
